package net.funtip.ormgenerator.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.funtip.ormgenerator.generator.TypeMapper;

public class Model {
	
	/**
	 # yuml.me - meta model
	 # http://yuml.me
	 
	[Entity]+1-*[Attribute]
	[Entity]+1-*[Method]
	[Entity]+1-*[Finder]
	[Entity]+1-*[UniqueConstraint]
	[UniqueConstraint]1-*[Attribute]
	[Attribute]^-[Association]
	[Association]1-1[Entity]
	[Entity]1-1[Identifier]
	[Attribute]^-[Identifier]
	[Finder]+1-*[FinderOperation]
	[FinderOperation]1-1[Attribute]

	 */

	private Map<String, Entity> entities;
	private String basePackageName;
	private TypeMapper typeMapper;
	
	public Model() {
		entities = new HashMap<String, Entity>();
	}

	public List<Entity> getEntities() {
		List<Entity> l = new ArrayList<Entity>();
		l.addAll(entities.values());
		return l;
	}
	
	public void addEntity(Entity e) {
		entities.put(e.getName(), e);
	}
	
	public Entity getEntity(String name) {
		return entities.get(name);
	}

	public String getBasePackageName() {
		return basePackageName;
	}

	public void setBasePackageName(String basePackageName) {
		this.basePackageName = basePackageName;
	}

	@Override
	public String toString() {
		return "Model [entities=" + entities + "]";
	}

	public TypeMapper getTypeMapper() {
		return typeMapper;
	}

	public void setTypeMapper(TypeMapper typeMapper) {
		this.typeMapper = typeMapper;
	}
	
}
